<?php

   session_start();
   $projectId = $_POST['selectedId'];
   include ("connection.php");

   function ConnectDB(){
      /*
      $mysqli = new mysqli("localhost", "root", "", "Garmor", 3306);
      if ($mysqli->connect_errno) {
          echo "Fallo al conectar a MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
      }
      */
      
      $mysqli = new connection();
      if ($mysqli->connect_errno) {
          echo "Fallo al conectar a MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
      }
      
      return $mysqli;
   }

      $link = ConnectDB();  

      $query = $link->prepare("SELECT i.ImageName, p.ProjectName, p.ProjectDescription, i.Section, p.ProjectStart, p.ProjectEnd FROM images i, projects p  WHERE i.ProjectId = p.ProjectId AND i.ProjectId = ? ");
      $query->bind_param("i", $projectId);
      $query->execute();
      $query->bind_result($imageName,$projectName,$projectDescription,$section,$projectStart,$projectEnd);
      while ($query->fetch()){
         echo ($imageName.',,,'.$projectName.',,,'.$projectDescription.',,,'.$section.',,,'.$projectStart.',,,'.$projectEnd.'::');
      }
      $query->close();
      //link->close();
?>


